package com.flyco.modules.stm.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.flyco.common.api.vo.Result;
import com.flyco.common.aspect.annotation.AutoLog;
import com.flyco.modules.stm.entity.StmReplenishment;
import com.flyco.modules.stm.entity.VZtbLgort;
import com.flyco.modules.stm.service.IVZtbLgortService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author hui_li
 * @Date 2022/12/13 13:07
 * @Version 1.0
 */
@Api(tags = "店铺库存地点")
@RestController
@RequestMapping("/f/oa/source")
@Slf4j
public class OaWldbController {
    @Autowired
    private IVZtbLgortService ivZtbLgortService;

    @ApiOperation(value = "仓库库存地点列表", notes = "仓库库存地点列表")
    @GetMapping(value = "/list")
    public Result<?> list(){
        Map<String, List<VZtbLgort>> map = ivZtbLgortService.list(Wrappers.lambdaQuery(VZtbLgort.class)
                .select(VZtbLgort::getId,VZtbLgort::getWerks,VZtbLgort::getLgobe)
                .eq(VZtbLgort::getBukrs, 1000).in(VZtbLgort::getWerks, Arrays.asList(1000, 1010)))
                .stream().collect(Collectors.groupingBy(VZtbLgort::getWerks));
        return Result.ok(map);
    }

}
